<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件处理指令</title>
    <!-- 引用vue.js库 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <button @click="counter+=1">{{counter}}</button>
        <button v-on:click="cl">{{message}}</button>
        <button  @click="say('h1')" >这就是一个按钮</button>
    </div>
    <script>
        let vm = new Vue({
            // 根据id获取到容器div
            el:"#app",
            // data表示数据
            data:{
                //数据部分
                counter:0,
                message:"hello",
                test:''
            },
            methods:{
                //点击某些按钮要触发的函数(方法)
                cl() {
                    //this表示当前对象自身(vm对象)
                    this.message = this.message+"vue.js!"
                },
                say(message) {
                    this.test = message;
                    alert(this.test);
                }
            }
        });
    </script>
    
</body>
</html>